package sg.edu.nus.iss.team2s.jass.dao;

/**
 * @author Aye Thazin Kyaw
 */

import java.util.Iterator;
import java.util.List;

import sg.edu.nus.iss.team2s.jass.dto.JobSeeker;

public class JobSeekerDAO extends AbstractPropertiesDAO {
	public static final String FILENAME = "JobSeeker";
	@Override
	public void add(Object obj) throws DAOException {
		/*
		 * This is method is left unimplemented as the maintenance of job seekers is out of
		 * scope. 
		 */
		throw new DAOException("adding job seekers is not supported in this version!");
	}

	@Override
	public Object get(String key) throws DAOException {
		List<Object> jobSeekerList = list();
		Iterator<Object> iterator = jobSeekerList.iterator();
		while(iterator.hasNext()){
			JobSeeker jobSeeker = (JobSeeker)iterator.next();
			String loginId = jobSeeker.getLoginName();
			if(loginId.equalsIgnoreCase(key)){
				return jobSeeker;
			}
		}
		return null;
	}

	@Override
	public List<Object> list() throws DAOException {
		List<Object> list = retrieve(FILENAME);
		return list;
	}

	@Override
	public void update(List<Object> list) throws DAOException {
		/*
		 * This is method is left unimplemented as the maintenance of job seekers is out of
		 * scope. 
		 */
		throw new DAOException("updating job seekers is not supported in this version!");
	}

}
